<?php


namespace App\Http\Repositories\ProductCenter;


use App\Http\Repositories\BaseRepository;
use App\Models\ProductCenter\Models\CarouselModel;

class CarouselRepository  extends BaseRepository
{
    public $carousel;
    public function __construct(CarouselModel $carousel)
    {
        $this->carousel = $carousel;
    }

    public function getCarouselInfo($data)
    {
        $where['id'] = $data['id'];
        return $this->carousel->getCarouselInfo($where);
    }

    public function getCarouselList($data)
    {
        $where = [];
        is_real_exists(@$data['type']) && $where['type'] = $data['type'];
        is_real_exists(@$data['status']) && $where['status'] = $data['status'];

        return $data['operate'] == 1
            ? $this->carousel->getListByPage($where)
            : $this->carousel->getList($where, '*', 'sort desc');

    }

    public function addCarousel($data)
    {
        return $this->carousel->addItem($data, true);
    }

    public function editCarousel($data)
    {
        $where['id'] = $data['id'];

        $this->carousel->editItem($where, $data);

        return [];
    }

    public function delCarousel($data)
    {
        return $this->carousel->deleteItem($data);
    }


}
